/*

=============================================================================

Copyright (c) 2010 Xiotex Studios Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by Xiotex Studios Ltd (http://xiotexstudios.com) and Oladotun Rominiy",
in the same place and form as other third-party acknowledgments. Alternately,
this acknowledgment may appear in the software itself, in the same form and
location as other such third-party acknowledgments.
 
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. 

=============================================================================

File:		SWFTypes.h
Author:		Byron Atkinson-Jones

Update(s):	(Ola)Dotun Rominiyi (28/10/2010) - replaced built-in types for
											   basic types

=============================================================================

*/

#ifndef __SWFTYPES_H__
#define __SWFTYPES_H__

#include <string>

typedef uChar8* swf_stream;

class CSWFPlayHead;
class CSWFTagList;

typedef struct _tagTagShort
{
	uInt32	m_dwTagID;
	uInt32	m_dwLength;
	
} SWF_TAG_SHORT, *PSWF_TAG_SHORT;

typedef struct _tagTagsInt32
{
	uInt32	m_dwTagID;
	uInt32	m_dwLength16;
	uInt32	m_dwLength;
	
} SWF_TAG_sInt32, *PSWF_TAG_sInt32;

typedef enum HeaderLengths
{
	SWF_SHORT_TAG_HEADER_LENGTH = 2,
	SWF_sInt32_TAG_HEADER_LENGTH = 6,
	
} SWF_TAG_HEADER_LENGTHS;


typedef struct _tagSWFRGB
{
	uChar8	m_R;
	uChar8	m_G;
	uChar8	m_B;
	
} SWF_RGB, *PSWF_RGB;

typedef struct _tagSWFRGBA
{
	uChar8	m_R;
	uChar8	m_G;
	uChar8	m_B;
	uChar8	m_A;
	
} SWF_RGBA, *PSWF_RGBA;

typedef struct _tagSWFRECT
{
	sInt32	m_dwXMin;
	sInt32	m_dwYMin;
	sInt32	m_dwXMax;
	sInt32	m_dwYMax;
	
} SWF_RECT, *PSWF_RECT;

typedef struct _tagSWFMatrixRecord
{
	float32	m_fScaleX;
	float32	m_fScaleY;
	float32	m_fRotateSkew1;
	float32	m_fRotateSkew0;
	float32	m_fTranslateX;
	float32	m_fTranslateY;
	
} SWF_MATRIX_RECORD, *PSWF_MATRIX_RECORD;

typedef struct _tagSWFColourTransform
{
	sInt32		m_lRAdd;
	sInt32		m_lGAdd;
	sInt32		m_lBAdd;
	sInt32		m_lAAdd;
	sInt32		m_lRMult;
	sInt32		m_lGMult;
	sInt32		m_lBMult;
	sInt32		m_lAMult;
	
	
} SWF_COLOUR_TRANSFORM, *PSWF_COLOUR_TRANSFORM;

typedef enum SWFOffsetSkips
{
	SWF_SKIP_BYTE		= 1,
	SWF_SKIP_WORD		= 2,
	
} SWF_SKIP_OFFSETS;

typedef enum SWFTwips
{
	SWF_TWIPS			= 20,
	
} SWF_TWIPS_VALUE;

typedef enum SWFMaxValues
{
	SWF_MAX_BYTE		= 0xff,
	
} SWF_MAX_VALUES;

typedef enum SWFEdgeTypeFlags
{
	SWF_NO_EDGE			= 0,
	SWF_EDGE			= 1,
	
} SWF_EDGE_FLAGS;

typedef enum SWFFillTypeValues
{
	SWF_SOLID_FILL					= 0x00,
	SWF_LINEAR_GRADIENT				= 0x10,
	SWF_RADIAL_GRADIENT				= 0x12,
	SWF_REPEATING_BITMAP			= 0x40,
	SWF_CLIPPED_BITMAP				= 0x41,
	SWF_NON_SMOOTHED_BITMAP			= 0x42,
	SWF_NON_SMOOTHED_CLIPPED_BITMAP	= 0x43,
	
} SWF_FILL_TYPE_VALUES;

typedef enum SWFShapeType
{
	SWF_SHAPE1	= 0,
	SWF_SHAPE2	= 1,
	SWF_SHAPE3	= 2,
	
} SWF_SHAPE_TYPE;


typedef enum SWFHeader
{
	SWF_F				= 0,
	SWF_W				= 1,
	SWF_S				= 2,
	SWF_FLASH_VERSION	= 3,
	SWF_FILE_SIZE		= 4,
	SWF_FRAME_SIZE		= 8,
	SWF_FRAME_RATE		= 17,
	SWF_FRAME_COUNT		= 19,
	SWF_START_OF_MOVIE	= 21,
	
} SWF_FILE_HEADER_BYTE_POSITIONS;

typedef enum SWF_TagNames
{
	SWF_END						= 0,
	SWF_SHOW_FRAME				= 1,
	SWF_DEFINE_SHAPE			= 2,
	SWF_PLACE_OBJECT			= 4,
	SWF_REMOVE_OBJECT			= 5,
	SWF_SET_BACKGROUND_COLOR	= 9,
	SWF_DEFINE_SHAPE_2			= 22,
	SWF_PROTECT					= 24,
	SWF_PLACE_OBJECT_2			= 26,
	SWF_REMOVE_OBJECT_2			= 28,
	SWF_DEFINE_SHAPE_3			= 32,
	SWF_DEFINE_SPRITE			= 39,
	SWF_FRAME_LABEL				= 43,
	SWF_EXPORT_ASSETS			= 56,
	SWF_IMPORT_ASSETS			= 57,
	SWF_ENABLE_DEBUGGER			= 58,
	SWF_ENABLE_DEBUGGER_2		= 64,
	SWF_SCRIPT_LIMITS			= 65,
	SWF_SET_TAB_LIMITS			= 66,
	
} SWF_TAG_NAMES;

typedef enum SWF_HeaderSizes
{
	SWF_RECT_HEADER_SIZE	= 5,
	
} SWF_HEADER_SIZES;

typedef struct _tagTag
{
	uInt32					m_dwType;
	uInt32					m_dwLength;
	swf_stream				m_pStream;
	uInt32					m_dwID;
	
	bool					m_bHasClipActions;
	bool					m_bHasClipDepth;
	bool					m_bHasName;
	bool					m_bHasColourTransform;
	bool					m_bHasMatrix;
	bool					m_bHasCharacter;
	bool					m_bHasMove;
	bool					m_bHasRatio;
	SWF_MATRIX_RECORD		m_mMatrix;
	uInt32					m_dwCharacterID;
	SWF_COLOUR_TRANSFORM	m_ColourTransform;
	std::string				m_strName;
	uInt32					m_dwClipDepth;
	uInt32					m_dwRatio;
	sInt32					m_iDepth;
	SWF_RECT				m_sRect;
	
	float32					m_fScaleX;
	float32					m_fScaleY;
	float32					m_fTX;
	float32					m_fTY;
	float32					m_fAngle;
	
	float32					m_fParentScaleX;
	float32					m_fParentScaleY;
	float32					m_fParentAngle;
	float32					m_fParentTX;
	float32					m_fParentTY;
	bool					m_bSetParent;
	
	float32					m_fWidth;
	float32					m_fHeight;
	
} SWF_TAG, *PSWF_TAG;


#endif // __SWFTYPES_H__

